package com.yanqu.road.server.gameplayer.module.activity.area;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.pb.cross3.activity.AreaWashePkProto;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.base.GeneralModule;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.area.AreaWasePkMgr;
import com.yanqu.road.server.manger.activity.entername.EnterNameActivityMgr;
import com.yanqu.road.server.pb.PlayerPb;
import com.yanqu.road.server.protocol.ChannelProtocol;

public class AreaWashePkModule extends GeneralModule {

    public AreaWashePkModule(GamePlayer player) {
        super(player);
    }

    @Override
    public boolean loadData() {
        return true;
    }

    @Override
    public boolean afterLoadData() {
        return false;
    }

    @Override
    public boolean saveData() {
        return false;
    }

    @Override
    public void afterLogin() {

        ActivityInfo activityInfo = AreaWasePkMgr.getActivityInfo();
        if(!ActivityMgr.activityInShowTime(activityInfo)){
            return;
        }
        //系统解锁
        if(EnterNameActivityMgr.isActivitySystemOpen(player, activityInfo)){

            //报名期间
            if(EnterNameActivityMgr.inEnterNameTime(activityInfo.getActivityId())){
                return;
            }
            AreaWashePkProto.ChannelAreaWashePkGetUserDataReq.Builder channelReq = AreaWashePkProto.ChannelAreaWashePkGetUserDataReq.newBuilder();
            channelReq.setUserKey(EnterNameActivityMgr.buildKeyMsg(player.getUserId()));
            channelReq.setActivityId(activityInfo.getActivityId());
            channelReq.setUserBaseInfo(PlayerPb.parsePlayerBaseTempMsg(player.getUserInfo()));
            player.sendChannelPacket(ChannelProtocol.N_AREA_WASHE_PK_DATA_SYNC, channelReq);
        }

    }
}
